package org.dandsoft.blackbox.mapreduce.dispatcher;

import java.io.Serializable;

/**
 * @author Vilyuzhanin Denis (Fin)
 */
public class ProcessId implements Serializable {
    private long id;

    public ProcessId(long id) {
        this.id = id;
    }

    public long getId() {
        return id;
    }

    public static ProcessId generate() {
        return new ProcessId(Double.doubleToRawLongBits(Math.random()));
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        ProcessId processId = (ProcessId) o;

        if (id != processId.id) return false;

        return true;
    }

    @Override
    public int hashCode() {
        return (int) (id ^ (id >>> 32));
    }
}
